"use strict";

/**
 * 课表考勤相关接口调用
 */
import Ajax from "../libs/ajax";

// 课表考勤
export function getClassAttendance(query) {
    if (query.page_num === undefined || query.page_size === undefined) {
        return new Promise((resolve, reject) => {
            resolve({ code: 2011, msg: "考勤查询参数缺失" });
        });
    }
    return Ajax.ajax({
        url: "/api/class_attendance/query",
        method: "post",
        data: query
    }).then(res => res.data);
}

export function updateClassAttendance(data) {
    return Ajax.ajax({
        url: "/api/class_attendance/update",
        data: data,
        method: "post",
        timeout:20*1000,
    }).then(res => res.data);
}

// 导出考勤
export function exportClassAttendance(query) {
    if (!query.ids) {
        return new Promise((resolve, reject) => {
            resolve({ code: 2011, msg: "参数缺失" });
        });
    }
    return Ajax.ajax({
        url: "/api/class_attendance/export",
        method: "post",
        data: query,
        responseType: 'blob'
    }).then(res => res.data);
}

export function deleteClassAttendance(data) {
    return Ajax.ajax({
        url: "/api/class_attendance/delete",
        data: data,
        method: "post"
    }).then(res => res.data);
}